package com.googlecode.yoohoo.xmppcore.protocol.stanza;

import org.junit.Assert;
import org.junit.Test;

import com.googlecode.yoohoo.xmppcore.protocol.XmlLangText;
import com.googlecode.yoohoo.xmppcore.protocol.stanza.Presence;

public class PresenceTest {
	@Test
	public void toXml() {
		String xml = "<presence/>";
		Presence presence = new Presence();
		Assert.assertEquals(xml, presence.toXml());
		
		xml = "<presence><show>dnd</show></presence>";
		presence = new Presence();
		presence.setShow("dnd");
		Assert.assertEquals(xml, presence.toXml());
		
		xml =
			"<presence xml:lang='en'>" +
				"<show>dnd</show>" +
				"<status>Hello, world!</status>" +
				"<status xml:lang='zh'>哈罗，世界！</status>" +
			"</presence>";
		presence = new Presence();
		presence.setXmlLang("en");
		presence.setShow("dnd");
		presence.getStatus().add(new XmlLangText("Hello, world!"));
		presence.getStatus().add(new XmlLangText("哈罗，世界！", "zh"));
		Assert.assertEquals(xml, presence.toXml());
	}
}
